package entities;

import util.DataVerify;

public class Cart 
{
	
	private String title;
	private String img;
	private int qty;
	private float price;
	private String action;
	
	
	
	public Cart() {
	}

	public Cart(String title, String img, int qty, String price, String action) {
	
	
		this.price = Float.valueOf(price);
		this.title = title;
		this.qty = qty;
		this.img = img;
		this.action = action;
		
		
	}
	
	public String getAction() {
		return action;
	}

	public void setAction(String action) {
		this.action = action;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getImg() {
		return img;
	}

	public void setImg(String img) {
		this.img = img;
	}

	public int getQty() {
		return qty;
	}

	public void setQty(int qty) {
		this.qty = qty;
	}

	public float getPrice() {
		return price;
	}

	public void setPrice(float price) {
		this.price = price;
	}
	
	public static Cart newInstance(String title, String img, int qty, String price,String action){

		DataVerify.verifyObject("price",Float.valueOf(price));
		DataVerify.verifyObject("title",title);
		DataVerify.verifyObject("qty",qty);
		DataVerify.verifyObject("img",img);
		DataVerify.verifyObject("action",action);
				
		
		return new Cart(title, img, qty, price, action);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((img == null) ? 0 : img.hashCode());
		result = prime * result + Float.floatToIntBits(price);
		result = prime * result + qty;
		result = prime * result + ((title == null) ? 0 : title.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Cart other = (Cart) obj;
		if (img == null) {
			if (other.img != null)
				return false;
		} else if (!img.equals(other.img))
			return false;
		if (Float.floatToIntBits(price) != Float.floatToIntBits(other.price))
			return false;
		if (qty != other.qty)
			return false;
		if (title == null) {
			if (other.title != null)
				return false;
		} else if (!title.equals(other.title))
			return false;
		return true;
	}

	
	
	
}
